package com.my.order.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @date 2020/10/14 9:05
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {

    private Integer code;
    private String msg;
    private Object object;

    public Result(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * 操作成功，并且返回数据，如果不返回数据可以将obj赋值为null
     * @param code
     * @param msg
     * @param object
     * @return
     */
    public static Result success(Integer code, String msg, Object object){
        return new Result(code,msg,object);
    }

    /**
     * 操作失败返回的code和msg
     * @param code
     * @param msg
     * @return
     */
    public static Result fail(Integer code,String msg){
        return new Result(code,msg);
    }

}
